package keter.web.controller;

import java.util.Map;

import keter.service.CodeListService;
import keter.service.UnitService;
import keter.web.util.MediaTypes;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CommonController extends KeterBaseController{
	
	@Autowired
	CodeListService service;  
	
	@Autowired
	UnitService uservice;  

	public static class Routes {
		private static final String Prefix = "framework/errors";
		static final String _404 = Prefix + "/404";
		static final String _403 = Prefix + "/403";
	} 

	public static class Views {
		private static final String Prefix = "framework/errors";
		static final String _404 = Prefix + "/404";
		static final String _403 = Prefix + "/403";
	}

	@RequestMapping(value = Routes._404, method = RequestMethod.GET)
	public String handle404() {
		return Views._404;
	}

	@RequestMapping(value = Routes._403, method = RequestMethod.GET)
	public String handle403() {
		return Views._403;
	}
	
	@RequestMapping(value = "/public/codelist/{codeKind}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
	@ResponseBody
	public Map<String, String> getCodeListByKind(@PathVariable String codeKind) throws Exception {
		return service.findByCodeKind(codeKind);
	}
}
